package kr.co.boogui.helper;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import kr.co.boogui.dao.MemberDAO;
import kr.co.boogui.model.MemberVO;


@WebServlet("/joinokhelper.bi")
public class joinokhelper extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest req, HttpServletResponse res) 
			throws ServletException, IOException {
		res.setContentType("text/html; charset=UTF-8");
		req.setCharacterEncoding("UTF-8");
		PrintWriter out = res.getWriter();
		MemberVO m = new MemberVO();
		m.setUid(req.getParameter("juid"));
		m.setPwd(req.getParameter("jpwd"));
		m.setUname(URLDecoder.decode(req.getParameter("namet")));
		m.setPhone(req.getParameter("hpt"));
		m.setEmail(req.getParameter("emt"));
		m.setAddr(URLDecoder.decode(req.getParameter("addr1"))+URLDecoder.decode(req.getParameter("addr2")));
		m.setUgenre1(URLDecoder.decode(req.getParameter("ugenre1")));
		m.setUgenre2(URLDecoder.decode(req.getParameter("ugenre2")));
		System.out.println(m.getUname());
		boolean mv = MemberDAO.insertMember(m);
		if (mv) { 
			req.setAttribute("action", "joinok.jsp");
			req.setAttribute("jo", "y");
			req.setAttribute("result", "success");
		} else {  
			req.setAttribute("result", "fail");
		}
		out.close();
	}
}
